<div class="login_section1">
	<img src="{:config('setting.logo')}?_t={:time()}" alt="">
</div>
<div class="login_section2" style="margin-top: 40px;">
	<form action="">
		<div class="f1 clearfix">
			<img src="__PUBLIC__/home/images/a2.png" alt="">
			<input type="text" name="selfphone" autocomplete="off" class="input1" placeholder="请输入手机号">
		</div>
		<div class="f1 clearfix" style="margin-bottom: 0px">
			<img src="__PUBLIC__/home/images/a3.png" alt="">
			<input type="password" name="passwd" class="input1" placeholder="请输入密码">
		</div>
		<div class="f1" style="border: none;">
			<input type="checkbox" checked="checked" class="input2"  id="check">
			<label for="check">
				<span class="s1">下次自动登录</span>
			</label>
		</div>
		<div class="sub">
			<button class="but1" id="btnSubmit" type="button">登录</button>
		</div>
		<div class="last clearfix">
			<p class="p1">还没有账号？ <a href="{:url('Index/register')}">立即注册</a></p>
			<p class="p2">
				<a href="{:url('Index/forget')}">忘记密码</a>
			</p>
		</div>
	</form>
</div>
<script>
	$(function(){
		var uname = localStorage.getItem('username');
        if(uname!=''){
            $("input[name='selfphone']").val(uname);
        }
		var upwd = localStorage.getItem('passwd');
        if(upwd!=''){
            $('input[name="passwd"]').val(upwd);
        }
	    $("#btnSubmit").click(function () {
            var data = {};
            data.selfphone = $.trim($("input[name='selfphone']").val());
            data.passwd = $.trim($("input[name='passwd']").val());
            if(data.selfphone == ""){
                layer.msg("手机号不能为空");
                return false;
            }
            if(data.passwd == ""){
                layer.msg("请输入密码");
                return false;
            }
            $.post("{:url('Index/login')}", data, function (res) {
                if(res.result_code == 0){
                    if($("#check").prop("checked")){
						localStorage.setItem("username", data.selfphone);
						localStorage.setItem("passwd", data.passwd);
                    }
                    location.href = "{:url('Index/index')}"
                }else{
                    layer.msg(res.result_info);
                }
            });

        });
	})
</script>
<script>
	$(".im2_2").click(function () {
		$(this).hide().siblings(".im2_1").show().siblings("input").attr("type","text");
	})
	$(".im2_1").click(function () {
		$(this).hide().siblings(".im2_2").show().siblings("input").attr("type","password");
	})
</script>
